(ns fx-clj.controls.a
  (:require [freactive.core :as f]
            [clojure.pprint :refer [pprint]]))

(doseq [[name value] (System/getProperties)]
  (prn (format "%-25s  [ %s ]" name value)))

(defmulti a
  (fn [a b]
    [(type a) (type b)]))

(defmethod a [String String] [x y]
  (println "String String"))

(defmethod a [String Object] [x y]
  (println "String Object"))

(defmethod a [Object Object] [x y]
  (println "Object Object"))

(a "1" "2")
(a (Object.) "2")
(a "1" (Object.))
(a (Object.) (Object.))

(def s0 (f/atom {:a {:b 1}}))
(def s1 (f/cursor s0 [:a :b]))
(def s2 (f/rx (inc @s1)))

(prn s0 (instance? clojure.lang.IDeref s0))
(prn s1 (instance? clojure.lang.IDeref s1))
(prn s2 (instance? clojure.lang.IDeref s2))

(defmulti b
  (fn [a b]
    [(type a) (type b)]))

(defmethod b [Object clojure.lang.IDeref] [x y]
  (println "IDeref"))

(defmethod b :default [x y]
  (println "Default"))

(b 1 s0)
(b 1 s1)
(b 1 s2)

(prn (str (char (inc (int \a)))))